package cn.ac.iscas.domain.component.reader;



import cn.ac.iscas.domain.common.EtlColumn;

import java.util.List;
import java.util.Map;

/**
 * mysql组件示例
 *
 * 示例程序，合适的时间删除
 *
 * 1.组件package统一处理，比如com.iscas.datasong.ig.component.{类名小写，如：mysqlreader}，jar的名字统一为{类名}.jar，这样再加上jar的名字就可以找到对应的类进行实例化
 * 2.每个组件自己维护一个json文件，用于描述前台页面应该如何展示该组件，{类名}.json
 */
@Deprecated
public class MysqlReader implements IReaderComponent {

    @Override
    public boolean init(Map<String, Object> parameters) {
        return false;
    }

    @Override
    public List<EtlColumn> getHeader() {
        return null;
    }

    @Override
    public List<Map<String, Object>> getSampleData(int count) {
        return null;
    }

    /**
     * 每个组件自己内部知道传入参数应该有哪些内容
     */
    class Key {
		public static final String InputTableName = "inputTableName";
		public static final String DBName = "dbName";
		public static final String IP = "ip";
		public static final String PASSWORD = "password";
		public static final String PORT = "port";
		public static final String USERNAME = "username";
	}


}


/**
 if (field.getType() == ColumnType.Boolean)
 sql.append(" CHAR(5)");
 else if (field.getType() == ColumnType.String) {
 int size = 255;
 if(field.getSize() != null && field.getSize()>0) {
 size = field.getSize();
 }
 if(size < 4096) {
 sql.append(" VARCHAR(" + size + ")");
 }else if(size < 65535) {
 sql.append(" TEXT");
 }else if(size < 16777215) {
 sql.append(" MEDIUMTEXT");
 }else{
 sql.append(" LONGTEXT");
 }
 }else if (field.getType() == ColumnType.Date)
 sql.append(" DATETIME");
 else if (field.getType() == ColumnType.Double)
 sql.append(" DOUBLE");
 else if (field.getType() == ColumnType.Float)
 sql.append(" FLOAT");
 else if (field.getType() == ColumnType.Integer)
 sql.append( " INT");
 else if (field.getType() == ColumnType.Long)
 sql.append( " BIGINT");
 else if (field.getType() == ColumnType.Short)
 sql.append( " SMALLINT");
 else if (field.getType() == ColumnType.TinyInt)
 sql.append( " TINYINT");
 else if (field.getType() == ColumnType.Object)
 sql.append( " MediumBlob");
 else if (field.getType() == ColumnType.Blob)
 sql.append( " BLOB");
 else{
 throw new DataSongException(
 Status.PARAM_ANALYZE_ERROR,"param analyze error: columnType invalidate="+field.getType() +" for columnName="+field.getName());
 }
 */
